<?PHP
 session_start();
 include("admin/include/db.php");
 include("includes/session.php");
 
 $userId = $_SESSION['user_id'];

 $sqlCourseData = mysql_query("SELECT sf.*,first_name,email 
												FROM software_courses as sf 
													LEFT JOIN software_user AS SU ON SU.id = sf.trainer_id 
												WHERE sf.batch_code = '".$_REQUEST['course_id']."'");
 $resCourseData  = mysql_fetch_array($sqlCourseData);
 
 $courses_id = $_REQUEST['courses_id'];
 $trainer_id = intval($_REQUEST['trainer_id']);
 $rating 	 = intval($_REQUEST['rating']);
 
 if($trainer_id > 0 && $rating > 0){
	mysql_query("UPDATE software_users_courses_assign set trainer_rating = '$rating' ,trainer_id  = '$trainer_id' 
								where courses_id = '$courses_id' AND user_id = '$userId'");	 
 }

?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?=TITLE_WEBSITE?></title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<script>
function set_rating(rating,trainer_id){
	window.location.herf = 'rate_your_teachers.php?rating='+rating+'&trainer_id='+trainer_id;
}
</script>
<body>
<center>
<div style="background:#179cc1; height:3px">&nbsp;</div>
<div style="width:990px;" align="center">
		<div id="header">
		<?php
    		include("includes/header.php");
   		?>
        </div>
    <div style="margin-top:20px;">
    	 <div style=" width:25%; float:left" >
        	 <?php include("includes/studentLeftMenu.php");?>
        </div>
        <div style="width:75%;float:left">
        	<table id="signInTbl" width="719" cellspacing="0" cellpadding="0"  class=" text">
                <tr style=" background:#000;color:#FFF; font-weight:bold" height="30" >
                            	<td style="color:#FFF" colspan="3">&nbsp;Rate your Trainer</td>
                             
                </tr>
                <tr height="30" bgcolor="#CCCCCC">
                	<td  style="padding-left:15px"><strong>Course Name</strong></td>
                    <td><strong>Trainer Name</strong></td>
                    <td><strong>Rating</strong></td>
                </tr>
                <?php

				$sqlCourses = mysql_query("SELECT name,sc.trainer_id,su.first_name,suca.courses_id,suca.trainer_rating FROM software_users_courses_assign as suca   
														   inner join software_courses as sc ON sc.name = suca.courses_id 
														   inner join software_user as su ON su.Id = sc.trainer_id 
												where user_id = '$userId'");
                while($resCourses = mysql_fetch_array($sqlCourses)){
                ?>
                <tr height="30" bgcolor="#F5F5F5">
               	 	<td width="249" align="left" style="padding-left:15px"><?php echo $resCourses["name"]?></td>
                    <td width="233" align="left"><?php echo $resCourses["first_name"]?></td>
                    <td width="233" align="left">
                    	<select id="rating_user" name="rating_user" class="textBox" onchange="window.location.href='rate_your_teachers.php?courses_id=<?php echo $resCourses["courses_id"]?>&trainer_id=<?php echo $resCourses["trainer_id"]?>&rating='+this.value" >
                        	<option value="" selected="selected" >Rate your teacher</option>
                        	<?php
                            for($i=1;$i<=10;$i++)
							{
							?>
                            <option value="<?php echo $i;?>" <?=($resCourses["trainer_rating"] == $i ? 'selected=selected' : '')?> ><?php echo $i;?></option>
                            <?php
							}
							?>
                        
                        </select>
                    </td>
                </tr>    
                <?php		
                }
                ?>
               <tr>
                     <td colspan="2" >&nbsp;</td>
                </tr>
                </table>
        	
        </div>
        <div style="clear:both"></div>
    </div>
    
    <div style="margin-top:23px; margin-bottom:21px" align="center" >
    	<?php
									$sqlAdvertise = mysql_query("SELECT * FROM software_advertise 
																	WHERE 
																		banner_status = 'Y' AND banner = 2
																		ORDER BY RAND()
																		");
									$resAdvertise = mysql_fetch_array($sqlAdvertise);
							
									$imgPath  = 'admin/upload_images/'.$resAdvertise["banner_image"];
									
								?>
								
    </div>
   </div>
   <div id="footer">
  		<?php include("includes/footer.php")?>
   </div>
</div>
	</div>
</center>
</body>
</html>
